<!--
  ~ Copyright (c) 2021 Zsj. All rights reserved.
  -->

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Login Success</title>
</head>
<body style="text-align: center">

<div>
    <h1>登录成功</h1>
    <div>
        <span>
            <h2>用户名：<span id="un" th:text="${un}"></span></h2>
        </span>
        <span>
            <h2>密码：<span id="pwd" th:text="${pwd}"></span></h2>
        </span>
    </div>
    <div>
        <h2>Secret: <span id="secret" th:text="${secret}"></span></h2>
    </div>
    <button onclick="logout()">注销</button>
</div>

<script>
    function logout() {
        const req = new XMLHttpRequest();
        req.open("GET", "/logout", false);
        req.send();
        if (localStorage.getItem('type') === null || localStorage.getItem('type') === '') {
            window.location.href = '/login/text';
        } else {
            window.location.href = '/login/' + localStorage.getItem('type');
        }
    }
</script>
</body>
</html>